home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2005 November
/
WNnov2005.iso
/
Windows
/
Equipement
/
hMailServer
/
hMailServer-4.1-Build-136.exe
/
{app}
/
Addons
/
Squirrelmail Plugins
/
hmailserver_vacation
/
options.php
< prev
next >
Wrap
PHP Script
|
2005-03-14
|
6KB
|
206 lines
<?php
chdir('..');
define('SM_PATH','../');
// include compatibility plugin
//
if (defined('SM_PATH'))
include_once(SM_PATH . 'plugins/compatibility/functions.php');
else if (file_exists('../plugins/compatibility/functions.php'))
include_once('../plugins/compatibility/functions.php');
else if (file_exists('./plugins/compatibility/functions.php'))
include_once('./plugins/compatibility/functions.php');
if (compatibility_check_sm_version(1, 3))
{
include_once (SM_PATH . 'include/validate.php');
include_once (SM_PATH . 'functions/page_header.php');
include_once (SM_PATH . 'include/load_prefs.php');
}
else
{
include_once ('../src/validate.php');
include_once ('../functions/page_header.php');
include_once ('../src/load_prefs.php');
}
global $vacationMessageSubmit, $messageText, $vacationStatus, $messageSubject,
$username, $data_dir, $color;
// get flag that tells us if this is a vacation
// message submission
//
compatibility_sqextractGlobalVar('vacationMessageSubmit');
// if a message and other info was submitted, process it here
//
if (isset($vacationMessageSubmit) && $vacationMessageSubmit == 1)
{
compatibility_sqextractGlobalVar('messageText');
compatibility_sqextractGlobalVar('vacationStatus');
compatibility_sqextractGlobalVar('messageSubject');
compatibility_sqextractGlobalVar('ccAddresses');
compatibility_sqextractGlobalVar('keepMessages');
// turn on vacation messaging
//
$obAccount = GetAccountObject($username);
if (isset($vacationStatus) && $vacationStatus == "on")
{
$obAccount->VacationMessage = $messageText;
$obAccount->VacationSubject = $messageSubject;
$obAccount->VacationMessageIsOn = true;
$obAccount->Save();
}
else
{
$obAccount = GetAccountObject($username);
$obAccount->VacationMessage = $messageText;
$obAccount->VacationSubject = $messageSubject;
$obAccount->VacationMessageIsOn = false;
$obAccount->Save();
}
$location = '../../src/options.php';
header('Location: ' . $location);
exit(0);
}
// pull previous settings from user prefs
//
$obAccount = GetAccountObject($username);
$messageText = $obAccount->VacationMessage();
$messageSubject = $obAccount->VacationSubject();
$vacationStatus = $obAccount->VacationMessageIsOn();
displayPageHeader($color, 'None', 'document.forms[0].elements["messageText"].focus();');
echo '<br>';
echo '<form method="POST"><input type="hidden" name="vacationMessageSubmit" value="1">'
. '<table width=95% align=center cellpadding=2 cellspacing=2 border=0>'
. '<tr><td bgcolor="' . $color[0] . '">'
. '<center><b>'
. _("Vacation / Autoresponder");
?>
</b></center>
</td>
</tr>
<tr>
<td align="center">
<table width="70%" cellspacing="2">
<tr>
<td valign="top">
<br>
<input type="checkbox" name="vacationStatus" value="on" <?php
if ($vacationStatus == 'on') echo ' CHECKED' ?>>
</td>
<td>
<br>
<b><?php echo _("Activate vacation autoresponder") ?></b>
</td>
</tr>
<tr>
<td colspan="2">
<br>
<b><?php echo _("Message text"); ?></b>:
<br>
<textarea name="messageText" rows="5" cols="50" wrap="off"><?php echo eregi_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $messageText); ?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<br>
<b><?php echo _("Message subject") . '</b> '
. _("(leave blank to use standard \"RE:\" syntax)"); ?>:
<br>
<input type="text" name="messageSubject" size="60" value="<?php echo $messageSubject; ?>">
</td>
</tr>
<tr>
<td align=right colspan="2">
<br>
<input type="submit" value="<?php echo _("Submit"); ?>">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
exit(0);
// displays simple error output page
//
function showError($message)
{
global $color;
displayPageHeader($color, 'None');
echo '<br><br><center><font color="' . $color[2] . '"><b>'
. $message
. '</b></font></center></body></html>';
}
function GetAccountObject($username)
{
// Extract domain part from email address
$iAtPos = strpos($username, '@');
$DomainName = substr($username, $iAtPos + 1);
$hCOMApp = new COM("hMailServer.Application");
$obDomain = $hCOMApp->Domains->ItemByName($DomainName);
if (!isset($obDomain))
{
echo "Can not fetch domain object.!";
die;
}
$obAccount = $obDomain->Accounts->ItemByAddress($username);
if (!isset($obAccount))
{
echo "Can not fetch account object.!";
die;
}
return $obAccount;
}
?>